From 77e3259f00febe2464bdae0062d185099338ef8b Mon Sep 17 00:00:00 2001
From: GamingasCZ <gamingforyou875@gmail.com>
Date: Sun, 12 Jun 2022 21:18:55 +0200
Subject: [PATCH] Quitting with unsaved changes now shows a better warning.

---
 src/GUI/PageRecord.cpp                      | 12 ++++++++++--
 src/common/Dialogs.cpp                      |  2 ++
 src/common/Dialogs.h                        |  2 ++
 src/translations/simplescreenrecorder_cs.ts |  9 +++++++--
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/GUI/PageRecord.cpp b/src/GUI/PageRecord.cpp
index 5849ea2f..5de7af0c 100644
--- a/src/GUI/PageRecord.cpp
+++ b/src/GUI/PageRecord.cpp
@@ -431,9 +431,17 @@ PageRecord::~PageRecord() {
 
 bool PageRecord::ShouldBlockClose() {
 	if(m_output_manager != NULL) {
-		if(MessageBox(QMessageBox::Warning, this, MainWindow::WINDOW_CAPTION,
+		enum_button answer = MessageBox(QMessageBox::Warning, this, MainWindow::WINDOW_CAPTION,
 					  tr("You have not saved the current recording yet, if you quit now it will be lost.\n"
-						 "Are you sure that you want to quit?"), BUTTON_YES | BUTTON_NO, BUTTON_YES) != BUTTON_YES) {
+						 "What would you like to do with it?"), BUTTON_SAVE | BUTTON_DISCARD | BUTTON_CANCEL);
+		if(answer == BUTTON_DISCARD) {
+			return false;
+		}
+		if(answer == BUTTON_CANCEL) {
+			return true;
+		}
+		if(answer == BUTTON_SAVE) {
+			OnRecordSave();
 			return true;
 		}
 	}
diff --git a/src/common/Dialogs.cpp b/src/common/Dialogs.cpp
index d5550e5e..50fc2a5d 100644
--- a/src/common/Dialogs.cpp
+++ b/src/common/Dialogs.cpp
@@ -38,6 +38,8 @@ enum_button MessageBox(QMessageBox::Icon icon, QWidget* parent, const QString& t
 		{BUTTON_YES_ALWAYS, QDialogButtonBox::tr("Yes, always"), QMessageBox::YesRole   , NULL},
 		{BUTTON_NO        , QDialogButtonBox::tr("&No")        , QMessageBox::NoRole    , NULL},
 		{BUTTON_NO_NEVER  , QDialogButtonBox::tr("No, never")  , QMessageBox::NoRole    , NULL},
+		{BUTTON_DISCARD   , QDialogButtonBox::tr("Discard")    , QMessageBox::AcceptRole, NULL},
+		{BUTTON_SAVE      , QDialogButtonBox::tr("Save")       , QMessageBox::YesRole   , NULL}
 	};
 
 	// add buttons
diff --git a/src/common/Dialogs.h b/src/common/Dialogs.h
index 8c64d44e..96adfc64 100644
--- a/src/common/Dialogs.h
+++ b/src/common/Dialogs.h
@@ -29,6 +29,8 @@ enum enum_button : int {
 	BUTTON_YES_ALWAYS = 0x0008,
 	BUTTON_NO         = 0x0010,
 	BUTTON_NO_NEVER   = 0x0020,
+	BUTTON_DISCARD    = 0x0040,
+	BUTTON_SAVE       = 0x0080,
 };
 
 // Shows a standard Qt dialog with translated buttons.
diff --git a/src/translations/simplescreenrecorder_cs.ts b/src/translations/simplescreenrecorder_cs.ts
index 9b8ca80c..30034d80 100644
--- a/src/translations/simplescreenrecorder_cs.ts
+++ b/src/translations/simplescreenrecorder_cs.ts
@@ -2207,9 +2207,9 @@ Tyto klávesy budou odchyceny a nebudou předány nahrávané aplikaci.</transla
     <message>
         <location filename="../GUI/PageRecord.cpp" line="435"/>
         <source>You have not saved the current recording yet, if you quit now it will be lost.
-Are you sure that you want to quit?</source>
+What would you like to do with it?</source>
         <translation>Aktuální nahrávka dosud nebyla uložena a pokud program ukončíte nyní, bude ztracena.
-Opravdu chcete program ukončit? </translation>
+Co s ní chcete dělat?</translation>
     </message>
     <message>
         <location filename="../GUI/PageRecord.cpp" line="447"/>
@@ -2551,6 +2551,11 @@ Tlačítko Spustit nahrávání je nahoře ;).</translation>
         <source>No, never</source>
         <translation type="unfinished">Ne, nikdy</translation>
     </message>
+    <message>
+        <location filename="../common/Dialogs.cpp" line="41"/>
+        <source>Discard</source>
+        <translation type="unfinished">Zahodit</translation>
+    </message>
 </context>
 <context>
     <name>QMessageBox</name>
